import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:get/get.dart';
import 'package:xingsu/page/publisher/web_page.dart';
import '../../util/app_util.dart';

class DetailTaskInfoPage extends StatelessWidget {
  final Map map;

  const DetailTaskInfoPage(this.map, {super.key});

  @override
  Widget build(BuildContext context) {
    Map detail_info = map["detail_info"] ?? {};
    Map data = detail_info["data"] ?? {};
    Map taskInfo = data["task_info"] ?? {};

    return CustomScrollView(
      slivers: [
        SliverToBoxAdapter(
            child: Padding(
          padding: const EdgeInsets.symmetric(horizontal: 15),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              const SizedBox(
                height: 10,
              ),
              const Text(
                "任务说明",
                style: TextStyle(color: Colors.white, fontSize: 16),
              ),
              const SizedBox(
                height: 10,
              ),
              Text(
                "任务时间:${AppUtil.timeStringFromTime(taskInfo["StartTime"] ?? 0)} - ${AppUtil.timeStringFromTime(taskInfo["EndTime"] ?? 0)}",
                style: const TextStyle(color: Color(0xFFB5B9C0), fontSize: 13),
              ),
              Html(
                  style: {
                    "html": Style(
                        color: const Color(0xFFB5B9C0),
                        fontSize: const FontSize(13)),
                  },
                  data: taskInfo["TaskRule"],
                  onLinkTap: (String? url, RenderContext context,
                      Map<String, String> attributes, element) {
                    if (url == null) return;
                    Get.to(() => WebPage(url));
                  })
            ],
          ),
        ))
      ],
    );
  }
}
